#define _CRT_SECURE_NOWARNINGS 1
#include<stdio.h>
#define MAX 100000
int fun(int a)
{
	int count = 0;
	while (a != 0)
	{
		count++;
		a = a / 10;
	}
	return count;
}
int* weishu(int i, int a[100], int j)
{
	if (i != 0)
	{
		a[j] = i % 10;
		weishu(i / 10, a, j + 1);
	}
	return a;
}
int flower(int i, int n, int* p)
{
	int j = 0, k = 0;
	int sum = 0;
	for (j = 0; j < n; j++)
	{
		int sumx = 1;
		for (k = 0; k < n; k++)
		{
			sumx *= *(p + j);
		}
		sum = sum + sumx;
	}
	return sum;
}
int main()
{
	int i = 0, j = 0;
	int* p = nullptr;
	for (i = 0; i <= MAX; i++)
	{
		int n = fun(i), a[100] = { 0 };
		p = weishu(i, a, j);
		if ((flower(i, n, p)) == i)
			printf("%d ", i);
	}
	return 0;
}